﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using XMLSchemaExtractor.Generator;
using XMLSchemaExtractor.Utility;
using System.Drawing;

namespace XMLSchemaExtractor
{
    public class Controller
    {
        private IO io;

        public Controller()
        {
            io = new IO();
        }

        public bool IsXmlWellFormed(string filePath)
        {
            return Common.IsXmlWellFormed(filePath);
        }

        public string[] GetXML(string filePath, out string[] message)
        {
            XmlDocument xmlDoc = io.LoadXmlDocument(filePath);
            XML xml = new XML(filePath);
            string[] xmlArray = xml.GetSchema();
            message = xml.GetMessage();
            return xmlArray;
        }

        public string[] GenerateDTD(string filePath, int minEnumInstances, int maxEnumValues, int minEnumRatio, int minFixed, int minIdValues, out string[] message)
        {
            DTD dtd = new DTD(filePath, minEnumInstances, maxEnumValues, minEnumRatio, minFixed, minIdValues);
            string[] dtdArray = dtd.GetSchema();
            message = dtd.GetMessage();
            return dtdArray;
        }

        public string[] GenerateXSD(string filePath, out string[] message)
        {
            XmlDocument xmlDoc = io.LoadXmlDocument(filePath);
            XSD xsd = new XSD(xmlDoc);
            string[] xsdArray = xsd.GetSchema();
            message = xsd.GetMessage();
            return xsdArray;
        }

        public Graphics GenerateORASS(string filePath, Graphics gfx, out string[] message)
        {
            ORASS orass = new ORASS(filePath, gfx);
            Graphics g = orass.GetSchema();
            message = orass.GetMessage();
            return g;
        }

    }
}
